<!-- 顾客投诉 -->
<template>
  <div class="mod-config">
    <div class="avue-crud">
      <el-table :data="dataList" border v-loading="dataListLoading">
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button type="text" icon="el-icon-collection" @click="complaintsInfo(scope.row.id)">详情</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="complainNum" label="投诉单号"></el-table-column>
        <el-table-column prop="customerCard" label="会员卡号"></el-table-column>
        <el-table-column prop="customerName" label="会员姓名"></el-table-column>
        <el-table-column prop="complaintsType" label="投诉类型" :formatter="complaintsTypeFormatter"></el-table-column>
        <el-table-column prop="createTime" label="投诉时间"></el-table-column>
        <el-table-column prop="estimatedProcessingDate" label="预处理时间"></el-table-column>
        <el-table-column prop="dealDate" label="处理时间"></el-table-column>
        <el-table-column prop="status" label="处理状态" :formatter="statusFormatter"></el-table-column>
      </el-table>
    </div>
    <div class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next"></el-pagination>
    </div>
    <!-- 弹窗，详情 -->
    <detail-form v-if="detailVisible" ref="detailForm"></detail-form>
  </div>
</template>

<script>
  import { getFeedbackInfoByPersonId } from '@/api/eims/customer-complaint.js'
  import { getCustomerCardByPersonId } from '@/api/eims/customer'
  import DetailForm from '../../eims/customer-complaint/detail'
  import { mapGetters } from "vuex"
  export default {
    data() {
      return {
        dataForm: {
          key: ""
        },
        dataList: [],
        searchShow: true,
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        dataListLoading: false,
        detailVisible: false
      };
    },
    components: {
      DetailForm
    },
    computed: {
      ...mapGetters(["permissions"])
    },
    methods: {
      // 初始化数据
      init(id) {
        this.personId = id
        this.$nextTick(() => {
          this.getDataList()
        })
      },
      // 获取数据列表
      getDataList() {
        this.dataListLoading = true;
        let params1 = {
          current: this.pageIndex,
          size: this.pageSize
        }
        let params2 = {personId: this.personId}
        getFeedbackInfoByPersonId(Object.assign(params1, params2)).then(response => {
          if(response.data.code == '0'){
            this.dataList = response.data.data.records
            this.totalPage = response.data.data.total
          }else{
            this.$message.error(response.data.msg)
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val;
        this.pageIndex = 1;
        this.getDataList();
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val;
        this.getDataList();
      },
      complaintsTypeFormatter(row, column, cellValue, index) {
        switch (cellValue) {
          case "01":
            return '商品质量'
            break
          case "02":
            return '验光'
            break
          case "03":
            return '销售'
            break
          case "04":
            return '加工质量'
            break
          case "05":
            return '已审检验核'
            break
          case "06":
            return '送货'
            break
          case "07":
            return '服务态度'
            break
          case "08":
            return '订单失误'
            break
          case "09":
            return '调整校配'
            break
          case "10":
            return '时间延误'
            break
        }
      },
      statusFormatter(row, column, cellValue, index) {
        switch (cellValue) {
          case 1:
            return '已处理'
            break
          case 2:
            return '处理中'
            break
          case 0:
            return '未处理'
            break
        }
      },
      complaintsInfo(id) {
        this.detailVisible = true
        this.$nextTick(() => {
          this.$refs.detailForm.init(id)
        })
      }
    }
  };
</script>
